package njust.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import njust.dao.ImageDao;
import njust.domain.Goods;
import njust.domain.Image;

public class ImageDaoImpl extends HibernateDaoSupport implements ImageDao{

	
	
	@Override
	public boolean addImage(Image image) {
		this.getHibernateTemplate().save(image);
		return true;
	}

	

	@Override
	public boolean deleteImage(int id) {
		Image image = (Image) this.getHibernateTemplate().get(Image.class, id);
		this.getHibernateTemplate().delete(image);
		return true;
	}

	@Override
	public List getAllImage() {
		List list = new ArrayList();
		// this.getHibernateTemplate().setCacheQueries(true);
		list = this.getHibernateTemplate()
				.find("from Image order by Id desc");
		return list;
	}

	@Override
	public Image getImageById(int id) {
		Image image = this.getHibernateTemplate().get(Image.class, id);
		return image;

	}

	

}
